package Q1;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int q = scanner.nextInt();
        while (q > 0) {
            q--;
            int num = scanner.nextInt();
            if (num % 2 == 0) {
                System.out.println(num);
                continue;
            }

            int count = 0; //该数中偶数的个数
            int index = -1; //偶数的下标
            String temp = num + "";
            for (int i = 0; i < temp.length(); i++) {
                if ((temp.charAt(i) - '0') % 2 == 0) {
                    count++;
                    index = i;
                }
            }
            if (count == 0) {
                //没有偶数
                System.out.println(-1);
            } else {
                temp = temp.substring(0, index) + temp.charAt(temp.length() - 1) +
                        temp.substring(index + 1, temp.length() - 1) + temp.charAt(index);
                System.out.println(temp);
            }
        }
    }

}
